﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using MyHotel_Common;
using System.Data.SqlClient;

namespace MyHotel_DAO
{
    public class NhomNguoiDungDAO : DAO
    {
        protected override object createObjectFromDatarow(System.Data.DataRow row)
        {
            NhomNguoiDung nhomND = new NhomNguoiDung();
            nhomND.MaChucVu = int.Parse(row["MaChucVu"].ToString());
            nhomND.MaNhanVien = int.Parse(row["MaNV"].ToString());

            return nhomND;
        }

        public bool themNhomNguoiDung(NhomNguoiDung nhomND)
        {
            string nameProc = "SP_THEM_NDD";
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MANV", nhomND.MaNhanVien);
            para[1] = new SqlParameter("@MACHUCVU", nhomND.MaChucVu);

            return DataProvider.executeStoreProcedureNonQuery(nameProc, para) == 1;
        }

        public bool xoaNhomNguoiDung(NhomNguoiDung nhomND)
        {
            string nameProc = "SP_DELETE_NHOMNGUOIDUNG";
            SqlParameter[] para = new SqlParameter[2];
            para[0] = new SqlParameter("@MANV", nhomND.MaNhanVien);
            para[1] = new SqlParameter("@MACV", nhomND.MaChucVu);

            return DataProvider.executeStoreProcedureNonQuery(nameProc, para) == 1;
        }
    }
}
